home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Toolbox / Visual Basic Toolbox (P.I.E.)(1996).ISO / mail / mailx6 / _setup.1 / SIMPLEVB.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-04-19  |  2.8 KB  |  127 lines

  1. unit Simplevb;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, StdCtrls, ExtCtrls, MXMAILX;
  8.  
  9. {$I mailxdef.int}
  10.  
  11. type
  12.   TSimpleForm = class(TForm)
  13.     btlLogon: TButton;
  14.     GroupBox1: TGroupBox;
  15.     Label2: TLabel;
  16.     szMsgNum: TLabel;
  17.     Bevel1: TBevel;
  18.     Label1: TLabel;
  19.     szCount: TLabel;
  20.     Label3: TLabel;
  21.     Label4: TLabel;
  22.     szSubject: TEdit;
  23.     szNoteText: TMemo;
  24.     btnFirst: TButton;
  25.     btnNext: TButton;
  26.     MXForm1: TMXForm;
  27.     MXSession1: TMXSession;
  28.     MXMessage1: TMXMessage;
  29.     procedure btlLogonClick(Sender: TObject);
  30.     procedure btnFirstClick(Sender: TObject);
  31.     procedure btnNextClick(Sender: TObject);
  32.     procedure FormCreate(Sender: TObject);
  33.     procedure FormUpdate;
  34.     function  IsSessionActive:Boolean;
  35.   private
  36.     { Private declarations }
  37.   public
  38.     { Public declarations }
  39.   end;
  40.  
  41. var
  42.   SimpleForm: TSimpleForm;
  43.  
  44. implementation
  45.  
  46. {$R *.DFM}
  47. uses MailSys;
  48.  
  49. procedure TSimpleForm.btlLogonClick(Sender: TObject);
  50. begin
  51.      MXSession1.Logon:=TRUE;
  52.      if IsSessionActive=TRUE then
  53.      begin
  54.           szCount.caption:=IntToStr(MXMessage1.MsgCount);
  55.           btnFirstClick(Sender);
  56.      end
  57.      else
  58.      begin
  59.           szCount.caption:='';
  60.           szSubject.Text:='';
  61.           szNoteText.Text:='';
  62.           szMsgNum.caption:='';
  63.      end;
  64. end;
  65.  
  66. procedure TSimpleForm.btnFirstClick(Sender: TObject);
  67. begin
  68.      if IsSessionActive=TRUE then
  69.      begin
  70.           MXMessage1.Action:=ACTION_FINDFIRST;
  71.           FormUpdate;
  72.      end;
  73.  
  74. end;
  75.  
  76. function  TSimpleForm.IsSessionActive:Boolean;
  77. begin
  78.      if MXSession1.Logon=TRUE then
  79.      begin                 
  80.           Result:=TRUE;
  81.      end
  82.      else
  83.      begin
  84.          Application.MessageBox('No Active Session available',
  85.                                 'Mail eXtension DEMO for DELPHI',
  86.                                 MB_ICONSTOP);
  87.          Result:=FALSE;
  88.      end;
  89. end;
  90.  
  91. procedure TSimpleForm.btnNextClick(Sender: TObject);
  92. begin
  93.      if IsSessionActive=TRUE then
  94.      begin
  95.           MXMessage1.Action:=ACTION_FINDNEXT;
  96.           FormUpdate;
  97.      end;
  98.  
  99. end;
  100.  
  101. procedure TSimpleForm.FormUpdate;
  102. begin
  103.      if (MXMessage1.ErrorNum<>0) then
  104.      begin
  105.           Application.MessageBox('Error Fetching Inbox message',
  106.                                  'Mail X DEMO for DELPHI',
  107.                                  MB_ICONINFORMATION);
  108.      end
  109.      else
  110.      begin
  111.           szSubject.Text:=MXMessage1.Subject;
  112.           szNoteText.Lines:=MXMessage1.NoteText;
  113.           szMsgNum.caption:=IntToStr(MXMessage1.FetchMsg);
  114.      end;
  115. end;
  116.  
  117. procedure TSimpleForm.FormCreate(Sender: TObject);
  118. var
  119.    MailSystem: TMailSystem;
  120. begin
  121.      MailSystem:=TMailSystem.Create(Self);
  122.      MailSystem.ShowModal;
  123.      MailSystem.Free;
  124. end;
  125.  
  126. end.
  127.